package com.intelligent.bot.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.intelligent.bot.base.exception.E;
import com.intelligent.bot.base.result.B;
import com.intelligent.bot.model.Video;
import com.intelligent.bot.model.base.BaseDeleteEntity;
import com.intelligent.bot.model.req.VideoAddReq;
import com.intelligent.bot.model.req.VideoGetListReq;
import com.intelligent.bot.model.req.VideoUpdateReq;
import com.intelligent.bot.service.IVideoService;
import lombok.extern.log4j.Log4j2;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/sys/video")
@Log4j2
@Transactional(rollbackFor = E.class)
public class VideoApi {

    @Resource
    IVideoService videoService;
    

    @RequestMapping(value = "list",name = "列表")
    public B<Page<Video>> list(@Validated @RequestBody VideoGetListReq req)  {
        return videoService.list(req);
    }

    @RequestMapping(value = "add",name = "添加")
    public B<Void> add(@Validated @RequestBody VideoAddReq req)  {
        return videoService.add(req);
    }


    @RequestMapping(value = "/update",name = "修改")
    public B<Void> update(@Validated @RequestBody VideoUpdateReq req)  {
        return videoService.update(req);
    }

    @RequestMapping(value = "delete",name = "删除")
    public B<Void> delete(@Validated @RequestBody BaseDeleteEntity req)  {
        return videoService.delete(req);
    }

}
